<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./axios.min.js"></script>
</head>

<body>
    <h1>文章详情</h1>
    <hr>
    <div class="container"></div>
    <script>
        var container = document.querySelector('.container')
        var id = location.search.slice(4)
        axios({
            url: 'https://cnodejs.org/api/v1/topics',
            method: 'GET',
            params: {
                id: id,
            }
        }).then(function (res) {
            // console.log(res.data.data);
            if (res.data.success) {
                html = ''
                res.data.data.forEach(function (item) {
                    if (item.id === id) {
                        html += `
                        <h2>${item.title}</h2>
                        <div>${item.author.loginname}</div>
                        <div>${item.content}</div>
                    `
                    }
                })
                container.innerHTML = html
            }


        })
    </script>
</body>

</html>